import React, { useEffect, useRef } from 'react'
import 'antd/dist/antd.css'
import 'react-markdown-editor-lite/lib/index.css'
import './index.less'
import RouteList from './route'
import { BrowserRouter as Router } from 'react-router-dom'
import { stores } from './stores'
import { Provider } from 'mobx-react'
import { AliveScope } from './pages/keepAlive/keepAlive'
import zhCN from 'antd/es/locale/zh_CN'
import { ConfigProvider } from 'antd'

const App = () => {

    const linkRef = useRef()

    localStorage.setItem("token", "123456")
    useEffect(() => {
        // let token = localStorage.getItem("token")
        // token = Math.random() > 0.5 ? token : null
        // if (!token) return
        // linkRef.current.href = `http://localhost:8002/?token=${token}`
        // linkRef.current.click()
    }, [])

	return (
		<AliveScope>
			<ConfigProvider locale={zhCN}>
				<Provider {...stores}>
                    <a href="" ref={linkRef} style={{display: "none"}} />
                    <Router>
						<RouteList />
					</Router>
				</Provider>
			</ConfigProvider>
		</AliveScope>
	)
}

const Demo = (props) => {
    let [count, setCount] = React.useState(100)
    function add() {
        setCount(count++)
        console.log('add',count)
        console.log('add',count)
    }
    console.log('render',count);
    return (
        <div>
            <h1>{count}</h1>
            <button onClick={add}>+</button>
        </div>
    );
}

export default App
